import axios from 'axios';
import Nprogress from 'nprogress';
import "nprogress/nprogress.css"
let requestB = axios.create({
    baseURL: "/api2",
    timeout: 10000
});

//设置请求拦截器
requestB.interceptors.request.use((config) => {
    Nprogress.start();
    //config:配置对象请求头【可以给后台携带数据】
    return config;
});

//设置响应拦截器
requestB.interceptors.response.use((res) => {
    //进度条结束
    Nprogress.done();
    return res.data;
}, (error) => {
    return Promise.reject(error);
});

export default requestB;